<template>
  <j-modal
    :title="title"
    :width="width"
    :visible="visible"
    switchFullscreen
    :okButtonProps="{ class:{'jee-hidden': disableSubmit} }"
    @cancel="close"
    cancelText="关闭">
    <a-card :bordered="false">
      <a-tabs style="margin-top: -20px" @change="tabChange">
        <a-tab-pane key="1" tab="收入">
        </a-tab-pane>
        <a-tab-pane key="2" tab="支出">
        </a-tab-pane>
      </a-tabs>
      <div>
        <a-table
          ref="table"
          size="middle"
          :scroll="{x:true}"
          rowKey="id"
          :columns="columns"
          :dataSource="dataSource"
          :pagination="ipagination"
          :loading="loading"
          class="j-table-force-nowrap"
          @change="handleTableChange">
        </a-table>
      </div>
    </a-card>
  </j-modal>
</template>

<script>

  import '@/assets/less/TableExpand.less'
  import { mixinDevice } from '@/utils/mixin'
  import { JeecgListMixin } from '@/mixins/JeecgListMixin'

  export default {
    name: 'GoldDetailList',
    mixins:[JeecgListMixin, mixinDevice],
    components: {

    },
    data () {
      return {
        description: '用户金币详情管理页面',
        title:'充值明细',
        width:800,
        visible: false,
        disableSubmit: true,
        columns:[
          {
            title:'金币余额',
            align:"center",
            dataIndex: 'changeGold',
            customRender:function (t,r) {
              if(r.changeType=='1'){
                return "+"+t+"金币"
              }else{
                return "-"+t+"金币"
              }
            }
          },
          {
            title:'充值方式',
            align:"center",
            dataIndex: 'changeDetail',
            customRender:function (t,r) {
              if(r.changeType=='1'){
                if(t=="金币充值"){
                  return "用户充值";
                }else{
                  return "后台充值";
                }
              }
              return t;
            }
          },
          {
            title:'时间',
            align:"center",
            dataIndex: 'createTime',
          },
          {
            title:'变动后金币',
            align:"center",
            dataIndex: 'lastGold',
          },
        ],

        url: {
          list: "/user/goldDetail/list",
        },
        dictOptions:{},
        superFieldList:[],

        disableMixinCreated:true
      }
    },
    created() {
    },
    computed: {
      importExcelUrl: function(){
        return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`;
      },
    },
    methods: {
      //打开
      open (userId) {
        this.visible=true;
        this.queryParam.userId=userId;
        this.queryParam.changeType="1";//默认查询第一个tab，收入
        this.loadData(1);
      },
      //关闭
      close () {
        this.visible = false;
      },

      //tab切换
      tabChange(key){
        if(key=="1"){
          this.columns[1].title="充值方式";
        }else{
          this.columns[1].title="说明";
        }
        this.queryParam.changeType=key;//默认查询第一个tab，收入
        this.loadData(1);
      }
    }
  }
</script>
<style scoped>
  @import '~@assets/less/common.less';
</style>
